package com.eboy.httpimgview;

import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;

import com.eboy.utils.StreamUtils;

public class ImageService {

	public static byte[] getImage(String s) throws Exception {
		URL url = new URL(s);
		HttpURLConnection conn = (HttpURLConnection)url.openConnection();
		conn.setConnectTimeout(5000);
		conn.setRequestMethod("GET");
		if (200 == conn.getResponseCode()) {
			InputStream stream = conn.getInputStream();
			return StreamUtils.ReadStream(stream);
		}	
		return null;
	}
}
